<?php
/**
 * View Elenco Eventi FULL LaFabbrica.org
 * 
 * @author     luigi.pastore (gigi@la-fabbrica.org)
 * @created    17-mag-2011
 * @package    LaFabbrica
 * @copyright  Copyright (c) 2011 Luigi Pastore
 */
?>
<link rel="stylesheet" href="/css/admin/progressbar.css" type="text/css" />
<?php
if( count( $this->events ) ):
    foreach( $this->events AS $event ) :
        ?>
        <tr class="selectable <?php echo ( in_array( $event['event_id'], (array) $this->selected ) ? 'selected' : '' ) ?>" id="event_<?php echo $event['event_id'] ?>" id="<?php echo $event['event_id'] ?>">
            <th># <?php echo $event['event_id'] ?></th>
            <td class="title">
                <?php echo $event['event_title'] ?>	
            </td>
            <td class="type">
                <?php echo $event['event_type_name'] ?>	
            </td>
            <td class="progress-bar">
                <?php
                if( count( $event['live'] ) != 0 )
                    $percentuale = ((int) count($event['tourbook']['steps']) / count( $event['live'] ) ) * 100;
                else
                    $percentuale = 0;
                
                switch(true):
                    case $percentuale == 100:
                        $style = 'success';
                    break;
                    case $percentuale > 33:
                        $style = 'attention';
                    break;
                    case $percentuale < 33:
                        $style = 'error';
                    break;
                    default:
                        $style = 'blue';
                    break;
                endswitch;
                ?>
                <div class="ui-progress-bar ui-container <?php echo $style ?>" id="progress_bar"  title="<?php echo count( $event['tourbook']['steps'] ) .' step su '. count( $event['live'] ) ; ?> live">
                    <div class="ui-progress" style="width:<?php echo ( $percentuale == 0 ) ? '100%' : $percentuale .'%' ?>">
                    </div>
                        <span class="ui-label">
                            <b class="value"><?php echo sprintf( '%d', $percentuale ); ?>%</b>
                        </span>
                </div>                
            </td>
            <td title="Selezionata" class="action">
                <a href="/admin/tourbook/elencolive/id/<?php echo $event['tourbook']['tourbook_id'] ?>/event_id/<?php echo $event['event_id'] ?>">
                    <img src="/images/admin/16x16/tourbook.png"/>
                </a>
            </td>
        </tr>
    <?php
    endforeach;
else:
    ?><tr class="result"><td colspan="5">Nessun elemento presente...</td></tr> <?php endif; ?>

